// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package config

import "github.com/openclarity/yara-rule-server/pkg/config"

const (
	DefaultYaraBinary  = "yara"
	DefaultYaracBinary = "yarac"
)

type Config struct {
	YaraBinaryPath    string              `yaml:"yara_binary_path" mapstructure:"yara_binary_path" json:"yara_binary_path"`
	CompiledRuleURL   string              `yaml:"compiled_rule_url" mapstructure:"compiled_rule_url" json:"compiled_rule_url"`
	RuleSources       []config.RuleSource `yaml:"rule_sources" mapstructure:"rule_sources" json:"rule_sources"`
	YaracBinaryPath   string              `yaml:"yarac_binary_path" mapstructure:"yarac_binary_path" json:"yarac_binary_path"`
	CacheDir          string              `yaml:"cache_dir" mapstructure:"cache_dir" json:"cache_dir"`
	DirectoriesToScan []string            `yaml:"directories_to_scan" mapstructure:"directories_to_scan" json:"directories_to_scan"`
}

func (c *Config) GetYaraBinaryPath() string {
	if c.YaraBinaryPath != "" {
		return c.YaraBinaryPath
	}

	return DefaultYaraBinary
}

func (c *Config) GetYaracBinaryPath() string {
	if c.YaracBinaryPath != "" {
		return c.YaracBinaryPath
	}

	return DefaultYaracBinary
}
